<?php
namespace service\services;


class BaseUserService extends CommonService
{
    /**
     * @api {loginFromTianWangXing} /loginFromTianWangXing/:token 从天王星登录
     * @apiGroup login
     * @apiParam {String} token 从天王星传过来的token
     * @apiSuccessExample 成功:
     *   *     HTTP/1.1 200 OK
     *  {
     *         {
     *            "id":10,
     *           "difficulty":1
     *          },
     *          {
     *             "id":11,
     *             "difficulty":2
     *          }
     * }
     * @param $token
     * @return mixed
     */
    function loginFromTianWangXing($token)
    {
        $user = token_verify($token);
        if ($user['uid'] && $user['uname']) {
            $return_data['isSuccess'] = 1;
            $return_data['err_info'] = "登陆成功";
            $data = array(
                "user_id" => $user['uid'],
                "username" => $user['uname'],
                "topic_id" => $user["topic_id"],
            );
            $this->setUserSessionInfo($data);
        } else {
            $return_data['isSuccess'] = 0;
            $return_data['err_info'] = "天王星接口出错";
        }
        return $return_data;
    }

    /**
     * 获取用户做的专题ID
     * @return mixed
     */
    function getTopicId()
    {
        $user=$this->getUserSession();
        return $user["topic_id"];
    }

    function getUserList($class_id)
    {
        $data=[
                ["id"=>1,"name"=>"qinfangge"],
                ["id"=>2,"name"=>"qinfangge1"],
            ];
        return $data;
    }

    function getClassList()
    {
        $data=[
            ["id"=>1,"name"=>"1班"],
            ["id"=>2,"name"=>"2班"]
        ];
        return $data;
    }



}
